﻿using DogModel;
using IDogService;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace DogAPI.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class UserInfoController : ControllerBase
    {
        protected readonly IUserInfoService userInfoService;

        public UserInfoController(IUserInfoService _userInfoService)
        {
            userInfoService = _userInfoService;
        }

        [HttpPost]
        [Authorize(Roles = "na")]
        public bool InsertUser(string name, string pwd)
        {
            userInfoService.Creat(new DogModel.UserInfo { Name = name, PassWord = pwd });
            return true;
        }

        [HttpGet]
        [Authorize]
        public List<UserInfo> GetAll()
        {
            return userInfoService.GetAll();
        }
    }
}